<?php

namespace Kateba\SiteBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;

/**
 * Category
 *
 * @ORM\Table()
 * @ORM\Entity(repositoryClass="Kateba\SiteBundle\Entity\CategoryRepository")
 */
class Category
{
    /**
     * @var integer
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * @var \Kateba\SiteBundle\Entity\Service[]
     *
     * @ORM\OneToMany(targetEntity="\Kateba\SiteBundle\Entity\Service", mappedBy="category", cascade={"remove"}, orphanRemoval=true)
     */
    private $services;
    
    /**
     * @var string
     * @Assert\NotBlank
     * @ORM\Column(name="nameEn", type="string", length=255)
     */
    private $nameEn;

    /**
     * @var string
     * 
     * @ORM\Column(name="nameAr", type="string", length=255, nullable=true)
     */
    private $nameAr;

    /**
     * @var string
     * @Assert\NotBlank
     * @ORM\Column(name="descriptionEn", type="text")
     */
    private $descriptionEn;

    /**
     * @var string
     *
     * @ORM\Column(name="descriptionAr", type="text", nullable=true)
     */
    private $descriptionAr;


    public function __toString() {
        return (string) $this->nameEn;
    }

    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set nameEn
     *
     * @param string $nameEn
     * @return Category
     */
    public function setNameEn($nameEn)
    {
        $this->nameEn = $nameEn;
    
        return $this;
    }

    /**
     * Get nameEn
     *
     * @return string 
     */
    public function getNameEn()
    {
        return $this->nameEn;
    }

    /**
     * Set nameAr
     *
     * @param string $nameAr
     * @return Category
     */
    public function setNameAr($nameAr)
    {
        $this->nameAr = $nameAr;
    
        return $this;
    }

    /**
     * Get nameAr
     *
     * @return string 
     */
    public function getNameAr()
    {
        return $this->nameAr;
    }

    /**
     * Set descriptionEn
     *
     * @param string $descriptionEn
     * @return Category
     */
    public function setDescriptionEn($descriptionEn)
    {
        $this->descriptionEn = $descriptionEn;
    
        return $this;
    }

    /**
     * Get descriptionEn
     *
     * @return string 
     */
    public function getDescriptionEn()
    {
        return $this->descriptionEn;
    }

    /**
     * Set descriptionAr
     *
     * @param string $descriptionAr
     * @return Category
     */
    public function setDescriptionAr($descriptionAr)
    {
        $this->descriptionAr = $descriptionAr;
    
        return $this;
    }

    /**
     * Get descriptionAr
     *
     * @return string 
     */
    public function getDescriptionAr()
    {
        return $this->descriptionAr;
    }
    /**
     * Constructor
     */
    public function __construct()
    {
        $this->services = new \Doctrine\Common\Collections\ArrayCollection();
    }
    
    /**
     * Add services
     *
     * @param \Kateba\SiteBundle\Entity\Service $services
     * @return Category
     */
    public function addService(\Kateba\SiteBundle\Entity\Service $services)
    {
        $this->services[] = $services;
    
        return $this;
    }

    /**
     * Remove services
     *
     * @param \Kateba\SiteBundle\Entity\Service $services
     */
    public function removeService(\Kateba\SiteBundle\Entity\Service $services)
    {
        $this->services->removeElement($services);
    }

    /**
     * Get services
     *
     * @return \Doctrine\Common\Collections\Collection 
     */
    public function getServices()
    {
        return $this->services;
    }
    
    public function getName($locale = 'en') {
        if ($locale == 'en') {
            return $this->nameEn;
        } else {
            if ($this->nameAr)
                return $this->nameAr;
            else
                return $this->nameEn;
        }
    }

    public function getDescription($locale = 'en') {
        if ($locale == 'en') {
            return $this->descriptionEn;
        } else {
            if ($this->descriptionAr)
                return $this->descriptionAr;
            else
                return $this->descriptionEn;
        }
    }
}